package nc.vo.am.proxy;

import java.util.Properties;

import nc.bs.framework.common.NCLocator;
import nc.bs.framework.common.RuntimeEnv;
import nc.bs.framework.naming.Context;

public class EmLocatorProxy {
	public static boolean isDebug = false; 
	public static Properties props = null;
	
	public EmLocatorProxy() {
		super();
	}

    public static Context getLocator() {
    	
    	if(!isDebug) {
    		return NCLocator.getInstance();
    	}
    	
		if(props == null) {		
			props = new Properties();
	        RuntimeEnv.getInstance().setProperty("CLIENT_COMMUNICATOR", "nc.bs.framework.comn.cli.JavaURLCommunicator");
	        props.setProperty("CLIENT_COMMUNICATOR", "nc.bs.framework.comn.cli.JavaURLCommunicator");
	        
	        RuntimeEnv.getInstance().setRunningInServer(false);
	        
	        String host = System.getProperty("nc.host", "localhost");
	        String port = System.getProperty("nc.port", "8080");
	        String baseURL = "http://" + host + ":" + port;

	
	        RuntimeEnv.getInstance().setProperty("SERVICEDISPATCH_URL", baseURL + "/ServiceDispatcherServlet");
	        props.setProperty("SERVICEDISPATCH_URL", baseURL + "/ServiceDispatcherServlet");
	        RuntimeEnv.getInstance().setProperty("CLIENT_COMMUNICATOR", "nc.bs.framework.comn.cli.JavaURLCommunicator");
	        props.setProperty("CLIENT_COMMUNICATOR", "nc.bs.framework.comn.cli.JavaURLCommunicator");
    	
		}
        return props == null ? NCLocator.getInstance():NCLocator.getInstance(props);
    }
}
